package com.woniu.woniuproject.mapper;

import com.woniu.woniuproject.entity.Admin;
import com.woniu.woniuproject.vo.ARmiddle;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface AdminMapper {
    @Select("select * from t_admin where adminname=#{value}")
     Admin selectAdminByName(String name);
    @Update("Update t_admin set password=#{pass} where adminname=#{adminname}")
     Integer updateAdminByPass(@Param("adminname") String adminname,@Param("pass") String pass);

    List<ARmiddle> selectAdmin(@Param("name") String name,@Param("role") String role);
    @Update("UPDATE t_admin SET `status`=2,adata=#{date} WHERE aId=#{rows}")
    int UpdatedeleteAdminbyId(@Param("rows") int rows, @Param("date") Date date);
    @Update("UPDATE t_admin SET `status`=1 WHERE aId=#{rows}")
    int UpdateaddAdminbyId(@Param("rows") int rows);
    @Insert("INSERT INTO t_admin (adminname,`password`,phone)VALUES (#{adminname},#{password},#{phone})")
    int addAdmin(@Param("adminname") String adminname,@Param("password") String password,@Param("phone") String phone);
    @Insert("INSERT INTO t_armiddle(adminId,roleId) VALUES (#{aId},2)")
    int updatearminddle(@Param("aId") int aId);
    @Select("select * from t_admin where phone=#{value}")
    Admin selectAdminByPhone(String phone);
    @Update("UPDATE t_admin SET `password`=#{pass} WHERE phone=#{phone}")
    int updateAdminPass(@Param("pass") String newpass,@Param("phone") String phone);
    @Select("select * from  t_admin ")
    List<Admin> selectAll();
    @Delete("delete from t_admin where aId=#{aId}")
    int deleteById(int aId);
}
